package com.lantosec.hmrp.modules.monitor.controller;


import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.core.mvc.BaseController;
import com.lantosec.hmrp.modules.monitor.entity.EvaluationEntity;
import com.lantosec.hmrp.modules.monitor.entity.EvaluationEventEntity;
import com.lantosec.hmrp.modules.monitor.entity.EvaluationItemEntity;
import com.lantosec.hmrp.modules.monitor.service.IMonitorEvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 *
 * 大屏综合考评控制器
 *
 * @author AutoCode
 * @since 2020-05-27
 */
@Api(value = "大屏综合考评控制器", tags = "大屏综合考评控制器")
@RestController
@RequestMapping("/monitor/evaluation")
@Log4j2
public class MonitorEvaluationController extends BaseController {
    @Autowired
    private IMonitorEvaluationService service;

    @GetMapping("getDeptRank")
    @ApiOperation(value = "科室考评排名")
    public Result<List<EvaluationEntity>> getDeptRank(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year
    ) {
        List<EvaluationEntity> param = service.getDeptRank(month,year);
        return Result.ok(param);
    }

    @GetMapping("getItemDetails")
    @ApiOperation(value = "科室考评项目事件明细")
    public Result<List<EvaluationItemEntity>> getItemDetails(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year,
            @ApiParam(value = "部门id") @RequestParam(name = "deptId") String deptId
    ) {
        List<EvaluationItemEntity> param = service.getItemDetails(month,year,deptId);
        return Result.ok(param);
    }

    @GetMapping("getEventDetails")
    @ApiOperation(value = "科室事件详情")
    public Result<List<EvaluationEventEntity>> getEventDetails(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year,
            @ApiParam(value = "考评项目ID") @RequestParam(name = "evalItemId") String evalItemId,
            @ApiParam(value = "部门id") @RequestParam(name = "deptId") String deptId
    ) {
        List<EvaluationEventEntity> param = service.getEventDetails(month,year,evalItemId,deptId);
        return Result.ok(param);
    }

    @GetMapping("getPersonalRank")
    @ApiOperation(value = "个人考评排名")
    public Result<List<EvaluationEntity>> getPersonalRank(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year
    ) {
        List<EvaluationEntity> param = service.getPersonalRank(month,year);
        return Result.ok(param);
    }

    @GetMapping("getPersonalItemDetails")
    @ApiOperation(value = "个人考评项目明细")
    public Result<List<EvaluationItemEntity>> getPersonalItemDetails(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year,
            @ApiParam(value = "用户id") @RequestParam(name = "userId") String userId
    ) {
        List<EvaluationItemEntity> param = service.getPersonalItemDetails(month,year,userId);
        return Result.ok(param);
    }

    @GetMapping("getPersonalEventDetails")
    @ApiOperation(value = "个人事件明细")
    public Result<List<EvaluationEventEntity>> getPersonalEventDetails(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year,
            @ApiParam(value = "考评项目ID") @RequestParam(name = "evalItemId") String evalItemId,
            @ApiParam(value = "用户id") @RequestParam(name = "userId") String userId
    ) {
        List<EvaluationEventEntity> param = service.getPersonalEventDetails(month,year,evalItemId,userId);
        return Result.ok(param);
    }

    @GetMapping("getDeclareTotal")
    @ApiOperation(value = "工作台个人或科室奖惩申报待审核汇总")
    public Result<Map<String,Integer>> getDeclareTotal() {
        String userId = getUserId();
        Map<String,Integer> param = service.getDeclareTotal(userId);
        return Result.ok(param);
    }

    @GetMapping("getEvaluationList")
    @ApiOperation(value = "工作台综合考评待办列表")
    public Result<List<EvaluationEntity>> getEvaluationList() {
        String userId = getUserId();
        List<EvaluationEntity> param = service.getEvaluationList(userId);
        return Result.ok(param);
    }

    @GetMapping("getMoralityTotal")
    @ApiOperation(value = "工作台医德医风待审核汇总")
    public Result<Map<String,Integer>> getMoralityTotal() {
        String userId = getUserId();
        Map<String,Integer> param = service.getMoralityTotal(userId);
        return Result.ok(param);
    }

    @GetMapping("getMoralityBackLog")
    @ApiOperation(value = "工作台医德医风待办列表")
    public Result<List<EvaluationEntity>> getMoralityBackLog() {
        String userId = getUserId();
        List<EvaluationEntity> param = service.getMoralityBackLog(userId);
        return Result.ok(param);
    }

    @GetMapping("getInternalList")
    @ApiOperation(value = "内部满意度待办列表")
    public Result<List<EvaluationEntity>> getInternalList() {
        String userId = getUserId();
        List<EvaluationEntity> param = service.getInternalList(userId);
        return Result.ok(param);
    }
}
